import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:恋恋
 * Date:2023-10-21
 * Time:12:22
 */
class MyThead extends Thread{
    @Override
    public void run() {
        while (true){
            System.out.println("这个是继承Thread的多线程");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
class MyRunnable implements Runnable{
    @Override
    public void run() {
        while (true){
            System.out.println("这是继承Runnable的多线程");
            try{
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class TheadTest {
    public static void main(String[] args) {
        Thread thread = new Thread(()-> {
            System.out.println("使用lambda表达式");
        });
        thread.start();
    }
//    public static void main(String[] args) {
//        Thread thread = new Thread(new Runnable() {
//            @Override
//            public void run() {
//                System.out.println("匿名内部类——实现Runnable");
//            }
//        });
//        thread.start();
//    }
//    public static void main3(String[] args) {
//        Thread thread = new Thread(){
//            @Override
//            public void run() {
//                System.out.println("匿名内部类——继承Thread");
//            }
//        };
//        thread.start();
//    }
    /**
    public static void main2(String[] args) {
        MyRunnable runnable = new MyRunnable();
        Thread thread = new Thread(runnable);
        thread.start();
        while (true) {
            System.out.println("主线程中的循环");
            //为了让这里打印慢点，方便观察
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
     **/
        /**
         public static void main1(String[] args) {
         MyThead myThead = new MyThead();
         myThead.start();
         while (true){
         System.out.println("主线程中的循环");
         //为了让这里打印慢点，方便观察
         try {
         Thread.sleep(1000);
         } catch (InterruptedException e) {
         e.printStackTrace();
         }
         }
         }
         **/
    }
